﻿using ArticleandSiteData;
using ModelClassLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上提供

namespace SplitViewOptions
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class MyfavoratePage : Page
    {
        public MyfavoratePage()
        {
            this.InitializeComponent();
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.NavigationMode == NavigationMode.New)
            {
                string temp = "?where={" + "\"" + "userid" + "\"" + ":" + "\"" +App.Loginuser.objectId +"\"" + "}";
                string url = App.UserArticleorSiteUrl + temp;
                Favratesites allsite = await BmobWebsiteData.Getfavoratesites(url);
                listview.ItemsSource = allsite.results.Reverse();
            }
        }

        private void Border_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Border obj = sender as Border;
            Result oneinfo = obj?.DataContext as Result;

            if (oneinfo != null)
            {
                App.Currenturl = new Uri(oneinfo.url, UriKind.RelativeOrAbsolute);
            }
            Frame.Navigate(typeof(HomePage));
        }
    }
}
